package com.homework0425.homework05;

public class BookTicket extends Thread{

    public static int ticket = 100;





    public void run(){

        while(true){
            synchronized (this){
                if(ticket>0){
                    System.out.println(this.getName()+"卖出一张票！");
                    ticket--;
                    System.out.println("剩余数量" + ticket );

                }else {
                    System.out.println("余票不足");
                    return;
                }


            }



        }




    }
}
